$(function() {
	//左侧列表
	$('.ful li:lt(4)').click(function() {
		$('.ful li:lt(4)').removeClass();
		$(this).addClass('activebgcolor');
	});
});
//告警列表,设备搜索 选中标识
let activedata=['warnlistcontent','seldevicelist','patrolcontent'];
const listactive={
	//列表选中高亮
	lactive(e){
		$(document).on('click','.'+e+'>div',function(){
			$('.'+e+'>div').removeClass('hblue');
			$(this).addClass('hblue');
		});
	},
	//关闭信息统计
	canvaclose(){
		$(document).on('click', '.canvaclose', function() {
			vm.canvashow = false;
		});
	}
};
//列表选中高亮
activedata.forEach(e=>{
	listactive.lactive(e);
});
//关闭信息统计
listactive.canvaclose();

//初始化vue
var vm = new Vue({
	el: '#htforweb',
	data: {
		//左侧列表
		leftcontentshow:true,
		//左侧列表详情
		leftdetailshow:true,
		//请求url
		// geturl:"http://119.3.226.167:6382",
		user: '',
		// 告警定位详情展示框
		wname: '',
		closewarntrue: false,
		//默认显示的tab
		activeName: 'pane3',
		//tab1
		pane1show: true,
		paneicon1: 'icon-jiankong',
		panename1: '监控视频',
		warntipsdata1: [],
		//tab2
		paneicon2: 'icon-xinxi',
		panename2: '基本信息',
		warntipsdata2: [],
		//tab3
		pane3show: true,
		paneicon3: 'icon-gaojing',
		panename3: '告警信息',
		warntipsdata3: [],
		//tab4
		pane4show: true,
		paneicon4: 'icon-icon-video',
		panename4: '关联视频',
		linkdata4: '',
		// warntipsdata4:[],
		// cavas图
		canvashow: false,
		arrow: false,
		//概览
		level1: '园区',
		level2: '',
		level2hide: false,
		level3: '',
		level3hide: false,
		//退出
		sshow: false,
		//左侧更多显示
		morecontentshow: false,
		//第一次开启告警
		onecheck:1,
		//告警信息
		warnshow: false,
		//设备搜索
		deviceshow: false,
		//电子巡更
		patrolshow: false,
		//视频轮播
		videoshow: false,
		//告警筛选
		checkednames: [],
		//告警列表
		warnlistdata: [],
		//是否保存外景视角
		isSaveView: false,
		//全选
		checkAll: false,
		checkedCities: [],
		cities: [],
		isIndeterminate: false,
		//左侧告警列表
		leftlist: [{
				id: '1',
				icon: 'icon-gaojing',
				name: '告警信息'
			},
			{
				id: '2',
				icon: 'icon-shebeisousuo',
				name: '设备搜索'
			},
			{
				id: '3',
				icon: 'icon-xuncha',
				name: '电子巡更'
			},
			{
				id: '4',
				icon: 'icon-shipin',
				name: '视频轮播'
			},
			{
				id: '5',
				icon: 'icon-tongji',
				name: '信息统计'
			},
			{
				id: '6',
				icon: 'icon-caidan',
				name: '更多'
			}
		],
		//更多
		morecontent: [{
				id: '3d',
				icon: 'icon-3d'
			},
			{
				id: '6',
				icon: 'icon-xingzou'
			},
			{
				id: '7',
				icon: 'icon-yingyan'
			}
		],
		// 是否是3d视图
		is3dView: true,
		//告警信息
		warninfodata: [{
				flag1: false,
				id: '1',
				name: '视频监控',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '2',
				name: '门禁设备',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '3',
				name: '一键报警',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '4',
				name: '对讲机',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '5',
				name: '高压电网',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '6',
				name: '电子围栏',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '7',
				name: '红外对射',
				num: '',
				flag: false
			},
			{
				flag1: false,
				id: '8',
				name: '限高报警',
				num: '',
				flag: false
			},
		],
		//设备搜索前筛选
		seldeviceprev: 'devname',
		//页数
		snum: 1,
		//搜索结果数量
		deviceselnum: 0,
		//下页无数据
		countnull: true,
		//设备查询
		seldevice: '',
		//设备查询数据
		seldevicelist: [],
		//巡更数据
		patrollistdata:[],
		//单条巡更详细2333
		patroldetail:[],
		//巡更条数
		patrolcount:0,
		//巡更模糊搜索
		selpatrol:'',
		//巡更开始
		//巡更视频停止时间
		Patroltime:5000,
		//当前到达的点2333
		currentpoint:'',
		//当前速度
		thisnum:'',
		//默认开始速度
		startslider:10000,
		patrolstartshow:false,
		//最小巡更速度
		minspeed:10000,
		//最大巡更速度
		maxspeed:60000,
		//巡更界面
		startpatroldata:[
			{id:1,name:'显示路线',icon: 'icon-zhanshi',color:'',flag:true},
			{id:2,name:'隐藏路线',icon: 'icon-yincang',color:'activebgcolor',flag:false},
			{id:3,name:'虚线',icon: 'icon-xuxian',color:'',flag:true},
			{id:4,name:'实线',icon: 'icon-shixian',color:'activebgcolor',flag:false},
			{id:5,name:'播放',icon: 'icon-bofang',color:'',flag:true},
			{id:6,name:'暂停',icon: 'icon-zanting',color:'activebgcolor',flag:false},
			{id:7,name:'第一视角',icon: 'icon-1shijiao',color:'activebgcolor',flag:false},
			{id:8,name:'自由视角',icon: 'icon-3shijiao',color:'',flag:true},
			{id:9,name:'重新播放',icon: 'icon-bofang',flag:false}
		],
		//采集界面
		PatrolFormData: {
		  name:'',
		  range: ''
		},
		dialogFormVisible: false,
		//采集返回的点位信息
		savepointarr:[],
		collectionstartshow:false,
		startcollectiondata:[
			{id:1,name:'保存',icon: 'icon-baocun'},
			{id:2,name:'退出',icon: 'icon-guanbi'}
		],
		// patrollistdata: [{
		// 		id: '1',
		// 		name: 'A1电子巡防'
		// 	}
		// ],
		//视频轮播
		// videodata:[
		// 	{id:'1',title:'自定义方案一自定义方案一自定义方案一自定义方案一',videostate:true,
		// 		videolistdata:[
		// 			{id:'1-1',name:'R1活动区东'},
		// 			{id:'1-2',name:'R2活动区西'},
		// 			],
		// 	},
		// 	{id:'2',title:'自定义方案二',videostate:true,
		// 		videolistdata:[
		// 			{id:'2-1',name:'R3活动区东'},
		// 			{id:'2-2',name:'R4活动区西'},
		// 			],
		// 	},
		// ],
		//展开的id
		activeNames: '',
		videodata: [],
		videolistdata: [],
		addid: [],
		videoeditflag: true,
		//列表中添加的所有视频
		listvideo: [],
		isvideolist: false,
		videolistid: '',
		vlistname: '',
		//信息统计数据
		canvasname: [],
		canvasnum: [],
		//右侧列表
		rightcontentdata: [{
				flag1: false,
				flag: false,
				id: '1',
				icon: 'icon-jiankong',
				name: '视频监控'
			},
			{
				flag1: false,
				flag: false,
				id: '2',
				icon: 'icon-menjin',
				name: '门禁'
			},
			{
				flag1: false,
				flag: false,
				id: '3',
				icon: 'icon-yijian',
				name: '一键报警'
			},
			{
				flag1: false,
				flag: false,
				id: '4',
				icon: 'icon-duijiangji',
				name: '对讲机'
			},
			{
				flag1: false,
				flag: false,
				id: '5',
				icon: 'icon-gaoya',
				name: '高压电网'
			},
			{
				flag1: false,
				flag: false,
				id: '6',
				icon: 'icon-weilan',
				name: '电子围栏'
			},
			{
				flag1: false,
				flag: false,
				id: '7',
				icon: 'icon-hongwai',
				name: '红外对射'
			},
			{
				flag1: false,
				flag: false,
				id: '8',
				icon: 'icon-xiangao',
				name: '限高报警'
			}
		],
		//当前设备状态
		DeviceStatus: '',
		//悬浮楼模型上提示框状态
		dnone: false, //告警面板状态
		getReportArr: [], //websocket推送，获取单条告警数组
		//八种设备音频
		voiceArr: [{
				id: '1',
				src: 'video.mp3'
			}, //视频监控
			{
				id: '2',
				src: 'door.mp3'
			}, //门禁
			{
				id: '3',
				src: 'oneClick.mp3'
			}, //一键报警
			{
				id: '4',
				src: 'talk.mp3'
			}, //对讲机
			{
				id: '5',
				src: 'grid.mp3'
			}, //高压电网
			{
				id: '6',
				src: 'fence.mp3'
			}, //电子围栏
			{
				id: '7',
				src: 'ray.mp3'
			}, //红外对射
			{
				id: '8',
				src: 'limit.mp3'
			} //限高报警
		],
		getAllDeviceTypeListData: [], //获取八种设备id
		//悬浮楼模型上提示框状态
		tipname: '双击进入模型',
		tshow: false,
		index: '',
		isAllAlarmShutUp:true  //是否所有的告警筛选已经关闭
	},
	created() {
		this.login();
		//开启loading
		// this.mloading();
		//获取登陆状态
		this.getcookis();
		//巡更列表
		this.getPatrolLineList('');
	},
	mounted() {
		this.getvideolist();
		this.getvideoall(1500);
		//默认隐藏双击进入提示
		//关闭loading
		// setTimeout(()=>{
		// 	this.vloading.close();
		// },2500);
		this.getAllDeviceTypeList();
		$('.mleft').hide();
		//默认创建一次园区内信息统计
		this.getcanvasdata('JG001');
	},
	methods: {
	
   submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
			  //显示提交框
			  this.dialogFormVisible = false;
			  //保存提交内容
			  this.savePatrolLine();
			  //置空
			  this.resetForm('PatrolFormData');
			  // console.log('提交成功');
          } else {
				// console.log('失败');
				return false;
          }
        });
      },
	  //表单重置
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
		//恢复初始视角
		FirstAngleView(e){
			if(event.keyCode==e || e==32){
				g3d.setCenter([modelConfig.setting.xg3dcenter*1,modelConfig.setting.yg3dcenter*1,modelConfig.setting.zg3dcenter*1]);
				g3d.setEye([modelConfig.setting.xview*1,modelConfig.setting.yview*1,modelConfig.setting.zview*1]);
			}
		},
		//悬浮设备放大高亮反之恢复最初状态(场景,悬浮设备,悬浮状态)
		hoverEquipment(name, e, state) {
			//设备tag
			var EquipmentTag = e.data.getTag();
			//设备类型
			var EquipmentType = e.data._displayName;
			//设备类型组
			var EquipmentTypedata=(EquipmentType == "视频监控" || EquipmentType == "门禁设备" || EquipmentType == "对讲机" || EquipmentType == "红外对射" || EquipmentType == "高压电网" || EquipmentType == "电子围栏"|| EquipmentType == "一键报警" || EquipmentType == "限高报警");
			if (EquipmentTag != undefined) {
				if (name == "园区") {
					if (state == "enter") {
						if (EquipmentTypedata) {
							e.data.setScale3d(3, 3, 3);
							if ($('.rul li').hasClass('activebgcolor') == false) modelHighLight.setHighLight([e.data]);
						} else {
							$('.mleft').show();
							$('.mleft').css('pointer-events', 'none');
							document.getElementsByTagName("body").item(0).style.cursor = "pointer";
							document.querySelector('.mleft').style = "top:" + movey + "px;left:" + movex + "px";
							this.tipshow(name, EquipmentTag);
						}
					} else {
						if (EquipmentTypedata) {
							e.data.setScale3d(1.5, 1.5, 1.5);
							if ($('.rul li').hasClass('activebgcolor') == false) modelHighLight.clearHighLight(e);
						} else {
							//楼模型时展示提示框start
							document.getElementsByTagName("body").item(0).style.cursor = "auto";
							$('.mleft').hide();
							this.tiphide();
						}
					}
				} else {
					if (state == "enter") {
						if (EquipmentTypedata) {
							e.data.setScale3d(3, 3, 3);
							if ($('.rul li').hasClass('activebgcolor') == false) modelHighLight.setHighLight([e.data]);
						}
					} else {
						if (EquipmentTypedata) {
							e.data.setScale3d(1.5, 1.5, 1.5);
							if ($('.rul li').hasClass('activebgcolor') == false) modelHighLight.clearHighLight(e);
						}
					}
				}

			}

		},
		//悬浮建筑提示显示
		tipshow(type, name) {
			if (type == '园区') {
				this.tipname = "双击进入" + name + "建筑";
			} else {
				if (name == '监控' || name == '设备' || name == '对射' || name == '电网') return;
				if(name=="NaN层"){
					this.tipname='';
					return
					}
				this.tipname = "双击进入" + name;
			};
			movex = movex - 130;
			movey = movey - 35;
			document.getElementsByTagName("body").item(0).style.cursor = "pointer";
			document.querySelector('.mleft').style = "top:" + movey + "px;left:" + movex + "px";
			$('.mleft').show();
			// this.tshow=true;
		},
		//悬浮建筑提示隐藏
		tiphide() {
			document.getElementsByTagName("body").item(0).style.cursor = "auto";
			$('.mleft').hide();
			// this.tshow=false;
		},
		//告警列表设备及数量
		getAllDeviceTypeList() {
			$.ajax({
				type: "post",
				url: "/jg-api/device/getAllDeviceTypeList",
				async: true,
				success: (res) => {
					this.getAllDeviceTypeListData = res.data;
					//console.log('res', this.getAllDeviceTypeListData);
				}
			});
		},
		//关闭告警面板
		closedPanel() {
			this.dnone = false;
		},
		//登陆状态
		getcookis() {
			var aa = window.location.href;
			// console.log('aa', aa);
			var bb = aa.split('/');
			// console.log('bb', bb);
			var hrefs = bb[0] + "//" + bb[2];
			// console.log('hrefs', hrefs);
			if (this.getCookie('user') == "") {
				window.location.href = hrefs + '/' + 'login.html';
			} else if (this.user == "未登录") {
				window.location.href = hrefs + '/' + 'login.html';
			}
		},
		getCookie(cname) {
			var name = cname + "=";
			var ca = document.cookie.split(';');
			for (var i = 0; i < ca.length; i++) {
				var c = ca[i].trim();
				if (c.indexOf(name) == 0) {
					return c.substring(name.length, c.length);
				}
			}
			return "";
		},
		//加载页
		mloading() {
			this.vloading = this.$loading({
				lock: true,
				text: 'Loading',
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			});
		},
		// 登陆
		login() {
			var u = window.location.href;
			if (u.lastIndexOf('?') != -1) {
				this.user = u.substring(u.lastIndexOf('?') + 1);
			} else {
				this.user = "未登录"
			}
		},
		// 拖动
		tabdrag(i) {
			var box = document.getElementsByClassName("tdrag")[i];
			var x, y;
			var isDrop = false;
			// 获取需要排除的元素
			box.onmousedown = function(e) {
				var elemCancel = $(e.target).closest('.nodrag');
				// 如果拖拽的是排除元素，函数返回
				if (elemCancel.length) {
				  return true;
				};
				var e = e || window.event;
				x = e.clientX - box.offsetLeft;
				y = e.clientY - box.offsetTop;
				isDrop = true;
			}
			document.onmousemove = function(e) {
				if (isDrop) {
					var e = e || window.event;
					var moveX = e.clientX - x;
					var moveY = e.clientY - y;
					var maxX = document.documentElement.clientWidth - box.offsetWidth;
					var maxY = document.documentElement.clientHeight - box.offsetHeight;
					moveX = Math.min(maxX, Math.max(0, moveX));
					moveY = Math.min(maxY, Math.max(0, moveY));
					box.style.left = moveX + "px";
					box.style.top = moveY + "px";
				} else {
					return;
				}
			}
			document.onmouseup = function() {
				isDrop = false;
			};
		},
		//获取模型信息
		getequipment(e) {
			// console.log(e);
			$.ajax('/jg-api/model/getModelInfo', {
				data: {
					modelId: e,
				},
				dataType: 'json',
				type: 'post',
				success: (res) => {
					$('.el-icon-close').trigger('click');
					modelConfig.setConfig(e, res.data);
					if (res.success) {
						const h = this.$createElement;
						this.$notify({
							title: res.data[0].buildName,
							dangerouslyUseHTMLString: true,
							message: '<h3 class="mt10"><strong>外模型ID：</strong>' +
							res.data[0].parentId + '</h3><h3 class="mt10"><strong>建筑名称：</strong>' +
							res.data[0].modelName + '</h3><h3 class="mt10"><strong>建筑说明：</strong>' +
							res.data[0].remarks + '</h3>',
							duration: 0,
							offset: 45
						});
						this.arrow ? $('.el-notification.right').css('right', '78px') : $('.el-notification.right').css('right', '')
					}
				}
			});
		},
		//获取设备模型信息
		getdev(devid, devtype) {
			$.ajax('/jg-api/device/getDeviceInfo', {
				data: {
					deviceId: devid
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if (data.success == true) {
						$('.el-icon-close').trigger('click');
						if (data.success) {
							// console.log(data.data)
							const h = this.$createElement;
							// console.log(devtype);
							switch (devtype) {
								case '视频监控':
									this.$notify({
										title: data.data.deviceTypeName,
										dangerouslyUseHTMLString: true,
										message: '<p class="mt10"><strong>设备ID：</strong>' + data.data.deviceId +
											'</p><p class="mt10"><strong>所属房间：</strong>' + data.data.address +
											'</p><p class="mt10"><strong>url：</strong>' + data.data.rtsp_url + '</p>',
										duration: 0,
										offset: 45
									});
									break;
								case '门禁设备':
									this.$notify({
										title: data.data.deviceTypeName,
										dangerouslyUseHTMLString: true,
										message: '<p class="mt10"><strong>设备ID：</strong>' + data.data.deviceId +
											'</p><p class="mt10"><strong>设备名称：</strong>' + data.data.deviceName +
											'</p><p class="mt10"><strong>房间：</strong>' + data.data.room + '</p>',
										duration: 0,
										offset: 45
									});
									break;
								case '对讲机':
									this.$notify({
										title: data.data.deviceTypeName,
										dangerouslyUseHTMLString: true,
										message: '<p class="mt10"><strong>设备ID：</strong>' + data.data.deviceId +
											'</p><p class="mt10"><strong>名称：</strong>' + data.data.deviceName +
											'</p><p class="mt10"><strong>房间：</strong>' + data.data.room +
											'</p><p class="mt10"><strong>对讲号码：</strong>' + data.data.address + '</p>',
										duration: 0,
										offset: 45
									});
									break;
								case '红外对射':
									this.$notify({
										title: data.data.deviceTypeName,
										dangerouslyUseHTMLString: true,
										message: '<p class="mt10"><strong>设备ID：</strong>' + data.data.deviceId +
											'</p><p class="mt10"><strong>编号：</strong>' + data.data.deviceId +
											'</p><p class="mt10"><strong>名称：</strong>' + data.data.deviceName + '</p>',
										duration: 0,
										offset: 45
									});
									break;
							}
							this.arrow ? $('.el-notification.right').css('right', '78px') : $('.el-notification.right').css('right', '')
						}
					} else {
						this.$message(data.message);
					}
				}
			})
		},
		// 显示退出
		showsignout() {
			this.sshow = !this.sshow;
		},
		// 退出
		signout() {
			this.sshow = false;
			this.$confirm('你确定要退出系统吗？')
				.then(e => {
					this.$message('跳转到登陆页');
					location.href = 'login.html';
				})
				.catch(e => {
					//取消
				});
		},
		//左侧点击
		leftlistclick(e) {
			switch (e.id) {
				case "1":
					// console.log('告警信息');
					this.deviceshow = this.patrolshow = this.videoshow = false;
					this.warnshow = !this.warnshow;
					break;
				case "2":
					// console.log('设备搜索');
					this.warnshow = this.patrolshow = this.videoshow = false;
					this.deviceshow = !this.deviceshow;
					break;
				case "3":
					// console.log('电子巡更');
					this.warnshow = this.deviceshow = this.videoshow = false;
					this.patrolshow = !this.patrolshow;
					break;
				case "4":
					// console.log('视频轮播');
					this.warnshow = this.patrolshow = this.deviceshow = false;
					this.videoshow = !this.videoshow;
					break;
				case "5":
					this.canvashow = !this.canvashow;
					// console.log('信息统计');
					//展开后创建图
					if (this.canvashow == true) {
						setTimeout(() => {
							this.addcanvas();
						}, 50);
					};
					if (this.warnshow == true || this.deviceshow == true || this.patrolshow == true || this.videoshow == true) {
						setTimeout(() => {
							$('#canvasmain').css('left', '467px');
						}, 50);
					};
					break;
				case "6":
					// console.log('更多');
					this.morecontentshow = !this.morecontentshow;
					break;
			}
		},
		//获取信息统计
		getcanvasdata(e) {
			$.ajax('/jg-api/model/getAllDeviceStats', {
				data: {
					modelId: e,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					// console.log(data)
					this.canvasname = [];
					this.canvasnum = [];
					$.each(data.data, (e, e1) => {
						this.canvasname.unshift(e1.deviceTypeName);
						this.canvasnum.unshift(e1.amount);
					});
					if (this.canvashow == true) {
						setTimeout(() => {
							this.addcanvas();
						}, 50)
					}
				}
			});
		},
		/**
		*从数据库获取告警列表，并刷新有关数据
		*@param arrids  设备类型ID数组，可以以逗号分开，并结尾
		* 如果只有一个逗号，则 取选择信息
		*/
		getwarnlist(arrids) {
			
			if (publicAlarmObj.isLock){
				return;
			}
			
			let devTypeIdList='';
			if (arrids==undefined || arrids==''){			
				for (x in this.warninfodata){
					if (this.warninfodata[x].flag){
						devTypeIdList+=this.warninfodata[x].id+',';
					}
				}
			}	
			else{
				devTypeIdList=arrids;
			}	

			$.ajax('/jg-api/alarm/getAlarmList', {
				data: {
					deviceTypeIds: devTypeIdList,
					pageNo: 1,
					pageSize: 9000
				},
				async:true,
				dataType: 'json',
				type: 'post',
				success: (data) => {
					publicAlarmObj.clearWarnData();
					if (!this.isAllAlarmShutUp){
					  this.warnlistdata = data.data;
					}
					//刷新左边的筛选信息
	                publicAlarmObj.getAlarmSummary();
					$.each(data.data, (e, e1) => {
						this.cities.push(e1.alarmId);
						if (publicAlarmObj.alarmDeviceIdList.indexOf(e1.deviceId) === -1){
							publicAlarmObj.alarmDeviceIdList.push(e1.deviceId);
						}
						
						if (publicAlarmObj.alarmModelIdList.indexOf(e1.modelId)==-1){
						   publicAlarmObj.alarmModelIdList.push(e1.modelId);
					    }
						let buildingTag=e1.modelId=='JG001'?e1.modelId:e1.modelId.slice(0,e1.modelId.indexOf('_'));
						let oldCount=publicAlarmObj.alarmBuildingSummary.get(buildingTag);
						publicAlarmObj.alarmBuildingSummary.set(buildingTag,oldCount*1+1);
					})
					//刷新告警有关数据					
					publicAlarmObj.fixalarmList();
				},
				error: function(e) {
					console.log(e)
				}
			});
		},
		//告警信息滑块
		//只需要设置标记和开关websocket（公共),其它不需要处理
		warncheck(e) {
			if(this.onecheck==1){
				setTimeout(()=>{if (e.flag == true && e.num != "")$(".vioce"+e.id)[0].play()},1000)
				this.onecheck=2;
			}else{
				if(e.flag!=false){
					if (e.flag == true && e.num != "")$(".vioce"+e.id)[0].play();
				}
			}
			this.cities = [];
			var arrids = '';
			this.warninfodata.forEach((e1) => {
				if (e1.flag == true) {
					arrids += e1.id + ',';
				}
			});
			
			//获取列表数据
			this.getwarnlist(arrids);
			
			//刷新统计信息
			//publicAlarmObj.getAlarmSummary();
			// 提示音
			if (e.flag !== false) { //如果当前筛选项是打开
			    this.isAllAlarmShutUp=false;
				if (!websocket || websocket.readyState !== 1) {
					console.log('init websoket');
					initWebsocket();//打开公共告警
				}
				//mp3.play();
				//按钮开启
				//获取数量
			} else {
				var allFalse = vm.warninfodata.every(function(item) {
					return item.flag === false;
				})
				if (allFalse) {
					this.isAllAlarmShutUp=true;
					this.warnlistdata=[];
					//不关闭，因为需要刷新数据
					//websocket.close();
					if (map.isGlobalScene) {
						g3d.dm().each(function(data) {
							if (data) {
								data.setStyle('body.color', undefined);
							}
						})
					}
				}
			}
			//消息提示
			const h = this.$createElement;
			this.$message({
				message: h('p', null, [
					h('span', null, e.name),
					h('i', {
						style: 'color: teal'
					}, e.flag ? "开启" : "关闭")
				])
			});
		},
		//展开后模块点击
		moreclick(e) {
			switch (e.id) {
				case "2d":
					this.morecontent[0].id = "3d";
					this.morecontent[0].icon = "icon-3d";
					this.is3dView = true;
					fixedView(this.is3dView,false);
					console.log('2D视图');
					break;
				case "3d":
					this.morecontent[0].id = "2d";
					this.morecontent[0].icon = "icon-2d";
					this.is3dView = false;
					fixedView(this.is3dView,false);
					console.log('3D视图')
					break;
				case "6":
					console.log('路线');
					break;
				case "7":
					$('.main2d').toggle();
					console.log('鹰眼');
					break;
			}
		},
		//批量确定
		batch() {
			var postchecked;
			var cheaklength = this.checkedCities.length;
			if (cheaklength == 0) {
				this.$message('请选择要处理的信息');
			} else {
				this.$confirm('是否批量处理告警信息?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					postchecked = this.checkedCities.join(',');
					publicAlarmObj.fixAlarm(postchecked);
					this.postwarn(postchecked, 2);
					this.checkAll = this.isIndeterminate = false;
					this.closewarntrue = false;
					this.checkedCities = [];
					this.$message({
						type: 'success',
						message: '处理成功!'
					});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消处理'
					});
				});
			}
		},
		//全选告警
		handleCheckAllChange(val) {
			//console.log(val)
			this.checkedCities = val ? this.cities : [];
			this.isIndeterminate = false;
		},
		//当前所选
		handleCheckedCitiesChange(value) {
			let checkedCount = value.length;
			this.checkAll = checkedCount === this.cities.length;
			this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
		},
		//查询是否有告警信息
		selwarntips(deviceId) {
			// console.log(deviceId)
			$.ajax('/jg-api/model/getDeviceAlarmList', {
				data: {
					deviceId: deviceId
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					// this.warntipsdata2=this.warntipsdata3=[];
					if (data.success == true) {
						if (data.data.length == 0) {
							this.warntipsdata3 = [''];
							this.pane3show = false;
						} else {
							//有告警信息
							this.pane3show = true;
							this.activeName = "pane3";
							this.warntipsdata3 = data.data;
							//获取关联视频url
							this.getvideourl(data.data[0].link, 'link');
						}
					} else {
						this.$message(data.message);
					}
				}
			});
		},
		//视频
		getvideourl(id, status) {
			$.ajax('/jg-api/model/getVideoInfo', {
				data: {
					deviceId: id
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if (data.success == true) {
						this.linkdata4 = '';
						if (status == 'warn') {
							this.warntipsdata1 = data.data;
							// console.log(11,this.warntipsdata1)
						} else if (status == 'link' && data.link != '') {
							this.linkdata4 = data.data[0].url;
							// console.log(33,this.linkdata4)
						} else {
							console.log('未知')
						}
						// this.warntipsdata1=[
						// 	{'url':'rtsp://192.168.1.249:8554/testRtsp'},
						// 	{'url':'rtsp://192.168.1.249:8553/testRtsp2'}
						// 	]
					} else {
						// this.$message(data.message);
					}
				}
			});
		},
		//告警/设备 定位
		//不同的操作，导致e的值不一
		warningposition(e, type) {
			// console.log(11,type)
			// console.log(111,e)
			// console.log(222,e.deviceId)
			// console.log('设备定位');
			publicAlarmObj.isWarnning = (e.alarmId != undefined);
			//设备详情隐藏
			$('.el-icon-close').trigger('click');
			this.selwarntips(e.deviceId);
			this.pane1show = this.pane4show = true;
			this.paneicon1 = 'icon-jiankong';
			this.panename1 = '视频监控';
			this.closewarntrue = true;
			let  isPosOk=true;
			//基本信息
			$.ajax('/jg-api/device/getDeviceInfo', {
				data: {
					deviceId: e.deviceId
				},
				dataType: 'json',
				async:false, //注意，此处必须使用同步方式，否则后面的会乱执行
				type: 'post',
				success: (data) => {
					// console.log(data)
					if (data.success == true) {
						this.warntipsdata2 = data.data;
						
						let modelFileName="";
						if (data.data.build == '园区') {
							modelFileName = '园区';
						}
						else{
						    modelFileName = data.data.build+data.data.floor;
						}
						var posDeviceId = data.data.deviceId;
						//外层为隐藏
						if (type != 'nowarn') {
							if (modelMap.curModelFileName==modelFileName){ 
							   //如果是当前模型，就不需要重载了模型
							   //直接创建标记，并飞过去
							   isPosOk=publicAlarmObj.positionDevice(posDeviceId,publicAlarmObj.isWarnning,null,null);							   
							}
							else{ //否则调用
							   loadModel(modelFileName, map, 'position', posDeviceId);
							}
						}
					} else {
						this.$message(data.message);
					}
				}
			});
			
			//如果定位失败，则返回
			if (!isPosOk){
				return ;
			}
			//获取设备视频地址
			this.getvideourl(e.deviceId, 'warn');
			var dtype = e.deviceTypeName == undefined ? e.deviceType : e.deviceTypeName;
			// console.log(dtype)
			switch (dtype) {
				case "视频监控":
					this.wname = '视频监控';
					this.activeName = "pane1";
					break;
				case "门禁设备":
					this.activeName = "pane2";
					this.wname = this.panename1 = '门禁设备';
					this.paneicon1 = 'icon-menjin';
					this.pane1show = this.pane4show = false;
					break;
				case "一键报警":
					this.activeName = "pane2";
					this.wname = '一键报警';
					this.pane1show = false;
					break;
				case "对讲机":
					this.activeName = "pane2";
					this.wname = '对讲机';
					this.pane1show = this.pane4show = false;
					break;
				case "高压电网":
					this.activeName = "pane2";
					this.wname = '高压电网';
					this.pane1show = false;
					break;
				case "电子围栏":
					this.activeName = "pane2";
					this.wname = '电子围栏';
					this.pane1show = false;
					break;
				case "红外对射":
					this.activeName = "pane2";
					this.wname = '红外对射';
					this.pane1show = false;
					break;
				case "限高报警":
					this.activeName = "pane2";
					this.wname = '限高报警';
					this.pane1show = false;
					break;
			}
		},
		//播放告警视频,测试
		// playwarnvideo(e){
		// console.log('测试结束用：'+e);
		// doGo(e);
		// },
		//告警确认
		warningdetermination(e) {
			this.$confirm('是否处理该条告警信息?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.postwarn(e, 1);
			}).catch(() => {
				console.log('取消处理')
			});
		},
		//处理告警确认
		postwarn(e, num) {
			num == 1 ? e = e.alarmId : e
			$.ajax('/jg-api/alarm/alarmConfirm', {
				data: {
					alarmIds: e
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if (data.success == true) {
						this.$message({
							type: 'success',
							message: '处理成功!'
						});
					} else {
						this.$message(data.message);
					}
				}
			});
		},
		//设备搜索
		postseldev(...e) {
			$.ajax('/jg-api/device/getDeviceList', {
				data: {
					deviceId: e[0],
					deviceName: e[1],
					deviceType: '',
					// deviceType:e[2],
					modelId: '',
					pageNo: e[3],
					pageSize: 20,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if (data.success == true) {
						//console.log(data.data)
						if (data.data.length == 0) {
							this.$message('暂无数据');
						}
						if (data.data.length >= 20) {
							this.countnull = false;
						}

						if (e[3] == 1) {
							if (data.count != 0) {
								this.deviceselnum += data.count;
								this.seldevicelist = data.data;
							}
						} else {
							if (data.count == 0) {
								this.countnull = true;
								return
							}
							this.deviceselnum += data.count;
							this.seldevicelist = this.seldevicelist.concat(data.data);
						}
					} else {
						this.$message(data.message);
					}
				}
			});
		},
		//设备搜索
		seldevicedata(e) {
			if (e == '') {
				this.$message("请输入搜索值");
				return
			}
			this.deviceselnum = 0;
			this.countnull == true;
			this.seldevicelist = [];
			document.querySelector('.seldevicelist').scrollTop = '0';
			switch (this.seldeviceprev) {
				case 'devid':
					this.postseldev(e, '', '', 1);
					break;
				case 'devname':
					this.postseldev('', e, '', 1);
					break;
					// case 'devtype':
					// this.postseldev('','',e,1);
					// break;
			}
		},
		//触底分页
		seldevicedataload() {
			if (this.seldevice == '') return
			switch (this.seldeviceprev) {
				case 'devid':
					if (this.countnull == false) {
						this.snum++;
						this.postseldev(this.seldevice, '', '', this.snum);
					} else {
						if (this.seldevicelist > 20) {
							this.$message("没有更多了");
						}
					}
					break;
				case 'devname':
					if (this.countnull == false) {
						this.snum++;
						this.postseldev('', this.seldevice, '', this.snum);
					} else {
						if (this.seldevicelist > 20) {
							this.$message("没有更多了");
						}
					}
					break;
					// case 'devtype':
					// if(this.countnull==false){
					//  this.snum++;
					//  this.postseldev('','',this.seldevice,this.snum);
					// }else{
					//  this.$message("没有更多了");
					// }
					// break;
			}
		},
		//电子巡更模块
		//关闭所有除巡更外的界面
		closeallui(e){
			if(e=='hide'){
				this.leftcontentshow=this.leftdetailshow=this.closewarntrue=this.canvashow=this.videoshow=this.patrolstartshow=this.collectionstartshow=this.arrow=false;
				$('.main2d').hide();
				setTimeout(()=>{$('.righthide').hide()},50);
				$('.el-icon-close').trigger('click');
			}else{
				this.leftcontentshow=this.leftdetailshow=true;
				$('.righthide').show();
			}
		},
		//开始采集
		startpatrol() {
			//清空保留的点位信息
			this.savepointarr=[];
			//房间内才执行采集
			if (modelConfig.modelLevelName=='floor'){
				//  initKeepWatch();
				map.isStartCollect = true;
				// this.$message("您已进入巡更路线采集模式，当前模式下无法进行场景层级切换");
				const h = this.$createElement;
				this.$message({
					duration:6000,
					message: h('p', null, [
						h('span', {	style: 'color: #3a8ee6'}, '您已进入巡更路线采集模式,'),
						h('span', {	style: 'color: red'}, '按P'),
						h('span', {	style: 'color: #3a8ee6'}, '增加采集点')
					])
				});
				this.closeallui('hide');
				this.collectionstartshow=true;
				this.tabdrag(3);
				//操作模型方法
				//当前模型id:modelMap.curModelId
				//线条模式，直线：曲线：elePatrolObj.polyLine.s({'shape.border.pattern': [16, 50]})
				//开始采集
				elePatrolObj.beginGather();
			}else{
				this.$message("必须在楼层模型才可以采集!");
			}
		},
		//采集操作界面
		collectionui(e){
			if(e.id==1){
				this.savecollection();
			}else{
				this.exitcollectionui();
			}
		},
		//保存巡更方案
		savecollection(){
			//采集错误不展示保存
			if(elePatrolObj.segments.length<2){
				this.$message('采集点位不足');
				return
			};
			this.dialogFormVisible=true;
		},
		//确定退出采集
		exitcollectionui(){
			this.$confirm('确定退出采集吗', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.cancelpatrol();
			}).catch(() => {
				console.log('取消退出')
			});
		},
		//取消采集
		cancelpatrol() {
			elePatrolObj.cancelGather();
			this.$message("已退出采集");
			this.closeallui('show');
			this.collectionstartshow=false;
			// this.PatrolListRefresh();
			// this.$message("没有可用于放弃的采集路线");
		},
		//删除巡更
		patroldel(e) {
			this.$confirm('确定删除此路线吗', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.delPatrolLine(e);
			}).catch(() => {
				console.log('取消删除')
			});
		},
		//获取巡更列表
		getPatrolLineList(e){
			$.ajax('/jg-api/patrol/getPatrolLineList', {
				data: {
					lineName: e,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if(data.success){
						this.patrolcount=data.count;
						this.patrollistdata=data.data;
					}
				}
			})
		},
		//根据状态刷新列表
		PatrolListRefresh(){
			if(this.selpatrol){
				this.getPatrolLineList(this.selpatrol);
			}else{
				this.getPatrolLineList('');
			}
		},
		//滑块值
		sliderval(thise,maxe){
			this.thisnum=maxe-thise;
			//设置最小(快)速度为minspeed:30000
			this.thisnum<this.minspeed?this.thisnum=this.minspeed:this.thisnum;
			elePatrolObj.playParam.setDuration(this.thisnum);
		},
		//展示巡更操作界面
		patrolui(e){
			let startindex=e.id;
			//双数
			if(startindex%2==0){
				if(this.startpatroldata[startindex-1].flag==true){
					this.startpatroldata[startindex-1].flag=false;
					this.startpatroldata[startindex-2].flag=true;
				}
				
			}else{
			//单数
				if(this.startpatroldata[startindex-1].name!=='重新播放'){
					if(this.startpatroldata[startindex-1].flag==true){
						this.startpatroldata[startindex-1].flag=false;
						this.startpatroldata[startindex].flag=true;
					}
				}else{
					this.startpatroldata[5].flag=this.startpatroldata[8].flag=false;
					elePatrolObj.rePlay();
					this.startpatroldata[4].flag=true;
				}
			};
			//操作事件
			//重新播放:elePatrolObj.rePlay()
			//视角:elePatrolObj.playParam.viewType="第一人称视角",自由视角
			//隐藏路径：elePatrolObj.playParam.setIsShowRoad=false
			//当前速度：elePatrolObj.avPlayControlParams.duration
			//巡更开始播放：elePatrolObj.beginPlay();
			//播放：elePatrolObj.resumePlay();
			//暂停：elePatrolObj.pausePlay();
			//重播：elePatrolObj.rePlay();
			this.patroluistatus(e.name,'handle');
		},
		//巡更点击状态记录
		patroluistatus(e,status){
			// console.log(e);
			//读取状态,默认进入
			if(status=='read'){
				switch (e) {
					case "显示路线":
						elePatrolObj.playParam.setIsShowRoad(true);
						break;
					case "隐藏路线":
						elePatrolObj.playParam.setIsShowRoad(false);
						break;
					case "虚线":
						elePatrolObj.playParam.setLinePattern([16,16]);
						break;
					case "实线":
						elePatrolObj.playParam.setLinePattern(null);
						break;
					case "播放":
						// elePatrolObj.resumePlay();
						break;
					case "暂停":
						clearTimeout(this.Patroltime);
						elePatrolObj.pausePlay();
						break;
					case "第一视角":
						elePatrolObj.playParam.setViewType('第一人称视角');
						break;
					case "自由视角":
						elePatrolObj.playParam.setViewType('自由视角');
						break;
					}
			}else{
				//手动触发
				switch (e) {
					case "显示路线":
						elePatrolObj.playParam.setIsShowRoad(false);
						break;
					case "隐藏路线":
						elePatrolObj.playParam.setIsShowRoad(true);
						break;
					case "虚线":
						elePatrolObj.playParam.setLinePattern(null);
						break;
					case "实线":
						elePatrolObj.playParam.setLinePattern([16,16]);
						break;
					case "播放":
						elePatrolObj.pausePlay();
						clearTimeout(this.Patroltime);
						// console.log('切换到暂停');
						break;
					case "暂停":
						elePatrolObj.resumePlay();
						break;
					case "第一视角":
						elePatrolObj.playParam.setViewType('自由视角');
						break;
					case "自由视角":
						elePatrolObj.playParam.setViewType('第一人称视角');
						break;
				}
			}
		},
		//关闭巡更操作界面
		closepatrolui(){
			this.$confirm('是否退出巡更', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.exitpatrolui();
			}).catch(() => {
				// console.log('取消退出');
			});
		},
		//退出巡更界面
		exitpatrolui(){
			//退出后判断是否存在重新播放状态
			if(this.startpatroldata[8].flag==true){
				this.startpatroldata[5].flag=this.startpatroldata[8].flag=false;
				this.startpatroldata[4].flag=true;
			};
			//先暂停动画
			// elePatrolObj.pausePlay();
			//退出巡更
			this.isvideolist=false;
			elePatrolObj.exitPlay();
			//界面退出
			this.patrolstartshow=false;
			this.closeallui('show');
			this.$message("巡更已退出");
		},
		//获取单条巡更信息
		getPatrolLineInfo(e){
				//外层界面隐藏,巡更界面展示
				this.closeallui('hide');
				this.patrolstartshow=true;
				this.tabdrag(2);
				//创建路线
				elePatrolObj.getLineInfo(e);
				//巡更开始
				elePatrolObj.beginPlay();
				//模型透明
				// elePatrolObj.playParam.setTransparent('rgb(0,0,0,.1)');
				setTimeout(()=>{
					this.startpatroldata.forEach(sdata=>{
						if(sdata.flag==true){
							this.patroluistatus(sdata.name,'read');
							// console.log(sdata.name);
						}
					});
				}, 500);
		},
		//保存巡更路线
		savePatrolLine(){
			let pointarrdata=[];
			this.savepointarr=elePatrolObj.exitGather();
			this.savepointarr.forEach(i=>{
				pointarrdata.push({
					xcode:i[0],
					ycode:i[1],
					zcode:i[2]
				})
			});
			// var pointarr=[
			// 	{
			// 		xcode:3035.78402,
			// 		ycode:-21,
			// 		zcode:-406.99357
			// 	},
			// ];
			$.ajax('/jg-api/patrol/savePatrolLine', {
				data: {
					modelId:modelMap.curModelId,				//当前所在模型ID
					lineName:this.PatrolFormData.name,			//巡更线路名称
					xangle:0,									//X轴视角：_position[x,z]
					yangle:0,									//Y轴视角：_54O
					zangle:0,									//Z轴视角：_position[x,z]
					pointArray:JSON.stringify(pointarrdata),	//线路顺序点位数值
					searchRadius:this.PatrolFormData.range		//搜索半径(浮点数值)
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if(data.success){
						// this.$message.success("保存方案成功");
						this.$message.success(data.message);
						//刷新列表
						this.PatrolListRefresh();
						//退出采集
						this.closeallui('show');
						this.collectionstartshow=false;
					}else{
						this.closeallui('show');
						this.collectionstartshow=false;
						this.$message.error(data.message);
					}
				}
			})
		},
		//删除单条巡更路线
		delPatrolLine(e){
			$.ajax('/jg-api/patrol/deletePatrolLine', {
				data: {
					lineId: e,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if(data.success){
						this.$message.success(data.message);
						this.PatrolListRefresh();
					}
				}
			})
		},
		//获取对应点位的视频
		getPatrolPointDevice(e){
			let pointId=this.patroldetail.data.pointArray[e].pointId;
			if(pointId!==undefined){
				// let pid=JSON.stringify(pointId);
				// console.log(pointId,typeof(pointId))
				$.ajax('/jg-api/patrol/getPatrolPointDevice', {
					data: {
						pointId: pointId,
					},
					dataType: 'json',
					type: 'post',
					success: (data) => {
						// console.log(data,pointId);
						if(data.success){
							//存在视频,则到达巡更点暂停,5s后继续执行
							elePatrolObj.pausePlay();
							this.Patroltime=setTimeout(()=>{
								elePatrolObj.resumePlay();
							},5000);
							//展示巡更点位视频
							this.videoplay('视频监控',data.data);
						}else{
							// console.log('该点位无视频');
							// this.$message(data.message);
						}
					}
				})
			}
			//模拟数据
			// watch: {
				//当前巡更点
				// currentpoint(){
					// elePatrolObj.pausePlay();
					// this.Patroltime=setTimeout(()=>{
					// 	elePatrolObj.resumePlay();
					// },5000);
			// 	}
			// },
			// let dd=[
			// 		{
			// 			"deviceId": " B1-JK1-1",
			// 			"deviceName": " R19教室云台",
			// 			"rtspUrl":"rtsp://admin:admin123@10.4.18.1:554/h264/ch1/main/av_stream"
			// 		},
			// 		{
			// 			"deviceId": " B1-JK1-2",
			// 			"deviceName": " R19教室广角",
			// 			"rtspUrl":"rtsp://admin:admin123@10.4.18.2:554/h264/ch1/main/av_stream"
			// 		},
			// 	];
			// this.videoplay('视频监控',dd);
		},
		// 手风琴改变
		// handleChange(e){
		//  console.log(e)
		// },
		//新建视频方案
		addvideolist(e) {
			$.ajax('/jg-api/group/saveDeviceGroupName', {
				data: {
					groupName: e,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					this.$message({
						type: 'success',
						message: '新建成功'
					});
					this.getvideolist();
				}
			})
		},
		//新建视频功能
		addprogramme() {
			this.$prompt('', '方案名称', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				inputPattern: /\S/,
				inputErrorMessage: '方案名称不允许为空'
			}).then(({
				value
			}) => {
				this.addvideolist(value);
				this.getvideolist();
				this.getvideoall(100);
			}).catch(() => {
				console.log('取消输入')
			});
		},
		//获取视频分组
		getvideolist() {
			$.ajax('/jg-api/group/getDeviceGroupList', {
				data: {},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					// console.log(data);
					this.videodata = data.data;
					this.videodata.map(i => {
						this.$set(i, 'videostate', true);
					});
				}
			})
		},
		//默认获取分组下视频
		getvideoall(e) {
			setTimeout(() => {
				this.videodata.map(i => {
					this.getgroupvideo(i.groupId);
				});
			}, e)
		},
		//获取分组下视频
		getgroupvideo(e, type) {
			$.ajax('/jg-api/model/getGroupDeviceList', {
				data: {
					groupId: e,
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					if (data.success == true) {
						// console.log(data.data);
						// this.addid = data.vdata;
						if (type == "edit") {
							this.addid = [];
							// var cc=[];
							data.data.map(i => {
								this.addid.push(i.deviceId)
								// this.addid=cc.join(',');
							})
						};
						// console.log(this.addid)
						if (data.count !== 0) {
							this.videodata.map(i => {
								if (i.groupId == data.data[0].groupId) {
									this.$set(i, 'vdata', data.data);
								}
							})
						} else {
							this.videodata.map(i => {
								if (i.groupId == e) {
									this.$set(i, 'vdata', '');
								}
							})
						}
					}
				}
			})
		},
		//保存分组下视频
		savegroupvideo(e) {
			if(this.addid.length==0){
				console.log("列表为空,不保存");
				return;
			};
			$.ajax('/jg-api/model/bindDeviceGroup', {
				data: {
					groupId: e,
					deviceIds: this.addid.join(','),
				},
				dataType: 'json',
				type: 'post',
				success: (data) => {
					// console.log(data);
					if (data.success == true) {
						this.getgroupvideo(e);
						this.$message.success(data.message);
					} else {
						console.log(data.message);
					}
				}
			})
		},
		//视频编辑
		videoedit(e) {
			this.videodata.map(i=>{
			//只允许编辑一个
			if(i.videostate==false)i.videostate=true;
			});
			//activeNames编辑展开
			this.activeNames=this.videolistid = e.groupId;
			this.$message("当前编辑状态，双击鼠标左键添加摄像头，超出4个设备自动保存");
			// 编辑过程中不能离开当前层级
			e.videostate = this.videoeditflag = false;
			this.addid = [];
			//获取分组下视频
			this.getgroupvideo(e.groupId, 'edit');
			this.isvideolist = false;
		},
		// 视频保存
		videosave(e) {
			e.videostate = this.videoeditflag = true;
			this.savegroupvideo(e.groupId);
		},
		// 视频方案删除
		videolistdel(e) {
			this.$confirm('确定删除此方案?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				$.ajax('/jg-api/group/deleteDeviceGroup', {
					data: {
						groupId: e,
					},
					dataType: 'json',
					type: 'post',
					success: (data) => {
						if (data.success == true) {
							this.getvideolist();
							this.getvideoall(50);
							this.$message.success('删除成功');
							this.isvideolist = false;
						}
					}
				});

			}).catch(() => {
				console.log('取消删除')
			});
		},
		// 方案所有视频播放
		videoplay(vname, vdata) {
			// console.log(vname,vdata);
			document.querySelector('.listvideos').style = "top:100px,right:200px"
			this.vlistname = vname;
			// console.log(vdata)
			if (vdata != undefined && vdata != '') {
				this.listvideo = [];
				vdata.map(i => {
					this.listvideo.push({
						'name': i.deviceName,
						'url': i.rtsp_url
					})
				});
				this.isvideolist = true;
			} else {
				this.$message("无视频");
				document.querySelector('.listvideos').style = "display:none"
			}
		},
		//单条视频播放
		videoaddress(i) {
			this.warningposition({'deviceId':i.deviceId,'deviceType':'视频监控'},'');
			this.closewarntrue = false;
			this.isvideolist=true;
			document.querySelector('.listvideos').style = "top:100px,right:200px"
			this.listvideo = [];
			this.vlistname = i.deviceName;
			this.listvideo.push({
				'url': i.rtsp_url
			});
			setTimeout(()=>{this.isvideolist = true},1000);
		},
		//单条视频删除
		delvideo(e) {
			// console.log(e)
			this.$confirm('确定删除此摄像头?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				$.ajax('/jg-api/group/unBindDeviceGroup', {
					data: {
						groupId: e.groupId,
						deviceId: e.deviceId
					},
					dataType: 'json',
					type: 'post',
					success: (data) => {
						if (data.success == true) {
							// this.getvideoall(80);
							this.getgroupvideo(e.groupId, 'edit')
							this.$message.success('删除成功');
							this.isvideolist = false;
						}
					}
				});
			}).catch(() => {
				console.log('取消删除')
			});
		},
		// 添加摄像头视频到分组
		addCamera(e) {
			//添加设备视频start
			if (this.videoeditflag == false) {
				if (e.data.getTag() != undefined && e.data._displayName != undefined && e.data._displayName == "视频监控") {
					if (this.addid.length > 0 && this.addid.indexOf(e.data.getTag()) != -1) {
						this.$message("已存在该设备");
						return;
					};
					if (this.addid.length <= 3) {
						this.$message("已添加" + (this.addid.length + 1) + "个设备");
						this.addid.push(e.data.getTag());
						if (this.addid.length == 4) $('.' + this.videolistid).trigger('click');
						// this.videosave({"groupId":this.videolistid});
					} else {
						// console.log('超出4个设备')
						this.$message("方案内最多保存四个摄像头");
					}
				}
			}
			//添加设备视频end
		},
		//右侧菜单
		allhighlight(e, i) {
			this.rightcontentdata.forEach(function(item, index) {
				if (index !== i) {
					item.flag1 = false;
				} else {
					item.flag1 = !e.flag1;
				}
			})
			//console.log(this.rightcontentdata);
			// const h = this.$createElement;
			if (this.$refs.rli[i].getAttribute('class') == 'activebgcolor') {
				//关闭所有此类设备告警
				modelHighLight.setDeviceHighLight(e.name, e.id, 'close');
				this.$refs.rli[i].setAttribute('class', '');
				this.DeviceStatus = [{
					name: e.name,
					status: false
				}];
				// this.$message({
				//   message: h('p', null, [
				// 	   h('span',{style:'color:skyblue'},"所有"),
				// 	   h('span',{style:'color:red'},e.name),
				// 	   h('span',{style:'color:green'},"关闭"),
				//   ])
				// });
			} else {
				//开启所有此类设备告警（圈选出来此类设备）,非此设备关闭
				modelHighLight.setDeviceHighLight(e.name, e.id, 'open');
				$('.rul li').removeClass();
				this.$refs.rli[i].setAttribute('class', 'activebgcolor');
				this.DeviceStatus = [{
					name: e.name,
					status: true
				}];
				//设备高亮提示
				// this.$message({
				//   message: h('p', null, [
				// 	   h('span',{style:'color:skyblue'},"所有"),
				// 	   h('span',{style:'color:red'},e.name),
				// 	   h('span',{style:'color:green'},"高亮"),
				//   ])
				// });
			}
		},
		//创建canvas
		addcanvas() {
			// console.log('创建canvans图')
			var canvasmain = document.getElementById('canvasmain');
			var myChart = echarts.init(canvasmain);
			option = {
				grid: {
					top: '2%',
					left: '15%',
					right: '8%',
					bottom: '2%',
					containLabel: false
				},
				color: ['#3398DB'],
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'shadow'
					}
				},
				//  toolbox: {
				//  feature: {
				// 	 dataView: {show: true, readOnly: false},
				// 	 magicType: {show: true, type: ['line', 'bar']},
				// 	 restore: {show: true},
				// 	 saveAsImage: {show: true}
				//  }
				// },
				legend: {
					data: ['信息统计'],
					textStyle: {
						color: '#fff'
					}
				},
				xAxis: {
					type: 'value',
					splitLine: {
						show: false,
					},
					"axisLine": {
						"show": false
					},
					"axisTick": {
						"show": false
					}
				},
				yAxis: {
					type: 'category',
					data: this.canvasname,
					axisLabel: {
						color: '#fff'
					},
					"axisLine": {
						"show": false
					},
					"axisTick": {
						"show": false
					}
				},
				series: [{
					// name:'信息统计',
					type: 'bar',
					barWidth: 15,
					data: this.canvasnum,
					label: {
						normal: {
							show: true,
							position: 'right',
							color: '#fff'
						}
					},
				}]
			};
			myChart.setOption(option);
			//创建关闭按钮
			$('#canvasmain').append(`<span class="canvaclose"><i class="iconfont icon-guanbi"></i></span>`)
		}
	},
	computed: {
		leftcontent() {
			const {
				warnshow,
				deviceshow,
				patrolshow,
				videoshow
			} = this
			return {
				warnshow,
				deviceshow,
				patrolshow,
				videoshow
			}
		},
		levels() {
			const {
				level2,
				level3
			} = this
			return {
				level2,
				level3
			}
		},
		drags() {
			const {
				isvideolist,
				closewarntrue
			} = this
			return {
				isvideolist,
				closewarntrue
			}
		}
	},
	watch: {
		//当前巡更点
		currentpoint(){
			// console.log(this.currentpoint);
			//调取点位附近监控
			this.getPatrolPointDevice(this.currentpoint-1);
			//重新播放
			if(this.patroldetail.data.pointArray.length===this.currentpoint){
				this.startpatroldata[4].flag=this.startpatroldata[5].flag=false;
				this.startpatroldata[8].flag=true;
			}
		},
		isvideolist() {
			if (this.isvideolist == true) this.closewarntrue = false
			//视频关闭后巡更开始
			if(this.patrolstartshow==true){
				// 巡更操作界面可拖动
				 this.tabdrag(2);
				// vm.startpatroldata[5].flag=true
				//巡更视频列表已关闭状态且当前不为暂停状态
				if(this.isvideolist!=true && this.startpatroldata[5].flag!=true){
					// console.log(111);
					//巡更过程中关闭视频,继续巡更
					clearTimeout(this.Patroltime);
					elePatrolObj.resumePlay();
				}
			}
		},
		closewarntrue() {
			if (this.closewarntrue == true) this.isvideolist = false
		},
		getReportArr() {
			this.dnone = true;
			setTimeout(() => {
				this.dnone = false;
			}, 4000)
		},
		drags() {
			//告警信息
			if (this.closewarntrue == true) {
				this.tabdrag(1);
				//视频列表
			} else if (this.isvideolist == true) {
				this.tabdrag(0);
			}
		},
		isSaveView(newval, oldval) {
			if (map.isGlobalScene) {
				return newval
			} else {
				this.$message('内层模型不可保存视角！');
				this.isSaveView = false;
			}
		},
		leftcontent(e) {
			if (this.warnshow == true || this.deviceshow == true || this.patrolshow == true || this.videoshow == true) {
				this.isvideolist = false;
				setTimeout(() => {
					$('#canvasmain').css('left', '467px');
				}, 50);
			} else {
				setTimeout(() => {
					$('.ful li').removeClass();
				}, 50);
				$('#canvasmain').css('left', '98px');
			}
		},
		seldeviceprev() {
			this.seldevice = '';
			this.deviceselnum = 0;
			this.seldevicelist = [];
		},
		arrow() {
			this.arrow ? $('.el-notification.right').css('right', '78px') : $('.el-notification.right').css('right', '')
		},
		levels() {
			let l2 = this.level2.slice(0, 2);
			let l3 = this.level3.slice(-2);
			var reg = /(^[\-0-9][0-9]*(.[0-9]+)?)$/;
			var isnum = new RegExp(reg);
			var iss = this.level2.slice(2, 3);
			isnum.test(iss) ? l2 = this.level2.slice(0, 3) : l2 = this.level2.slice(0, 2)

			if (this.level3!='') {
				vm.tiphide()
				document.getElementsByTagName("body").item(0).style.cursor = "auto";
				// console.log(11,l3)
				switch (l3) {
					case '1层':
						l3 = l2 + '_' + 1
						// console.log(l3);
						this.getcanvasdata(l3);
						break;
					case '2层':
						l3 = l2 + '_' + 2
						// console.log(l3);
						this.getcanvasdata(l3);
						break;
					case '3层':
						l3 = l2 + '_' + 3
						// console.log(l3);
						this.getcanvasdata(l3);
						break;
				}
			} else {
				if (this.level2!='') {
					vm.tiphide()
					document.getElementsByTagName("body").item(0).style.cursor = "auto";
					$('.el-icon-close').trigger('click');
					//视频轮播隐藏
					this.isvideolist = false;
					this.getcanvasdata(l2);
				} else {
					this.getcanvasdata('JG001');
					//视频轮播隐藏
					this.isvideolist = false;
					// console.log('都不存在')
					//进入模型提示
					$('.mleft').hide();
					// g3d.flyTo(g3d.dm().getDataByTag("F2"), {
					// 	animation: true,
					// 	ratio: .1,
					// 	center:[-9395.55518,406.22149,11170.76121],
					// });
				}
			}
		}
	}
})